﻿#ifndef SPECTRUMPLAYBACKWEBSOCKETSERVER_H
#define SPECTRUMPLAYBACKWEBSOCKETSERVER_H

#include "spectrumplaybackwebsocketclient.h"

#include <QMutex>
#include <QThread>
#include <QWebSocket>
#include <QWebSocketServer>

class SpectrumPlaybackWebSocketServer : public QThread
{
    Q_OBJECT
public:
    /**
    * 获取单例实例
    * @return 返回单例实例
    */
    static SpectrumPlaybackWebSocketServer* getInstance();
    /**
    * 删除单例实例
    */
    static void deleteInstance();
private:
    explicit SpectrumPlaybackWebSocketServer(QObject *parent = nullptr);
    ~SpectrumPlaybackWebSocketServer();

    static SpectrumPlaybackWebSocketServer* instance;
    static QMutex mutex;
private slots:
    void handleNewConnection();
private:
    QWebSocketServer *m_server;
protected:
    void run() override;
};

#endif // SPECTRUMPLAYBACKWEBSOCKETSERVER_H
